package com.bytedance.scenedemo.navigation.popto;

import com.bytedance.scene.Scene;
import com.bytedance.scene.ktx.SceneExtensions;
import com.bytedance.scenedemo.ResourceTable;
import com.bytedance.scenedemo.utility.ColorUtil;
import ohos.aafwk.content.Intent;
import ohos.agp.components.*;

/**
 * Created by JiangQi on 8/3/18.
 */
public class PopToScene_2 extends Scene {
    @Override
    public Component onCreateView(LayoutScatter scatter, ComponentContainer container, Intent intent) {
        Component layout=scatter.parse(ResourceTable.Layout_single_task_demo_scene,container,false);
        ScrollView svMain= (ScrollView) layout.findComponentById(ResourceTable.Id_sv_single_task_demo_scene_main);
        Text textHint= (Text) layout.findComponentById(ResourceTable.Id_text_single_task_demo_scene_hint);
        Text textPath= (Text) layout.findComponentById(ResourceTable.Id_text_single_task_demo_scene_path);
        Button btnGoTo= (Button) layout.findComponentById(ResourceTable.Id_btn_single_task_demo_scene_goto);
        Button btnGoTo1= (Button) layout.findComponentById(ResourceTable.Id_btn_single_task_demo_scene_goto1);

        svMain.setBackground(ColorUtil.getMaterialColor(3));
        textHint.setText(getClassName());
        textPath.setText(SceneExtensions.getNavigationScene(this).getStackHistory());

        btnGoTo.setText("点击返回到 PopToScene_0");
        btnGoTo.setClickedListener(component -> {
            SceneExtensions.getNavigationScene(this).popTo(PopToScene_0.class);
        });
        btnGoTo1.setText("点击返回到栈底");
        btnGoTo1.setClickedListener(component -> {
            SceneExtensions.getNavigationScene(this).popToRoot();
        });

        return layout;
    }
}
